import os

# 调用本地7z程序进行解压
command = '7z x -o{unz_location} -p{password} {filepath} -y -bse0'


def uncompress(filepath, password):
    unz_location = os.path.join(os.path.dirname(filepath), os.path.basename(filepath).split('.')[0])
    result = os.popen(command.format(unz_location=unz_location, password=password, filepath=filepath))
    res = result.read()
    result.close()
    return res.find('Ok') != -1
